| 
									
										
										
										
											2015-07-14 16:45:03 +00:00
										 |  |  | #! /bin/sh | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | OS=`uname -s` | 
					
						
							|  |  |  | DEBUG=0 | 
					
						
							| 
									
										
										
										
											2020-07-03 00:36:23 -04:00
										 |  |  | PREFIX=/usr/local | 
					
						
							| 
									
										
										
										
											2015-07-14 16:45:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | create_linux_config_h() { | 
					
						
							|  |  |  |     cat <<EOF > src/config.h | 
					
						
							|  |  |  | #ifndef _CONFIG_H | 
					
						
							|  |  |  | #define _CONFIG_H | 
					
						
							|  |  |  | #include <endian.h> | 
					
						
							|  |  |  | #endif /* _CONFIG_H */ | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | create_darwin_config_h() { | 
					
						
							|  |  |  |     cat <<EOF > src/config.h | 
					
						
							|  |  |  | #ifndef _CONFIG_H | 
					
						
							|  |  |  | #define _CONFIG_H | 
					
						
							|  |  |  | #include <architecture/byte_order.h> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __LITTLE_ENDIAN__ | 
					
						
							|  |  |  | #define __DO_SWAP_BYTES | 
					
						
							|  |  |  | #endif /* _DO_SWAP_BYTES */ | 
					
						
							|  |  |  | #endif /* _CONFIG_H */ | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | create_common_build_mk() { | 
					
						
							|  |  |  |     if [ "$DEBUG" = 1 ]; then | 
					
						
							| 
									
										
										
										
											2020-07-03 00:36:23 -04:00
										 |  |  |         cat <<'EOF' > mk/build.mk | 
					
						
							| 
									
										
										
										
											2015-07-14 16:45:03 +00:00
										 |  |  | CGFLAGS		= -g -fno-inline | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2020-07-03 00:36:23 -04:00
										 |  |  | 		cat <<'EOF' > mk/build.mk | 
					
						
							| 
									
										
										
										
											2015-07-14 16:45:03 +00:00
										 |  |  | CGFLAGS		= | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2020-07-03 00:36:23 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	cat <<'EOF' >> mk/build.mk | 
					
						
							|  |  |  | CWFLAGS		= -Wall | 
					
						
							|  |  |  | COFLAGS		= -O2 | 
					
						
							|  |  |  | CFLAGS		= $(CGFLAGS) $(CWFLAGS) $(COFLAGS) | 
					
						
							|  |  |  | EOF | 
					
						
							| 
									
										
										
										
											2015-07-14 16:45:03 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | create_linux_build_mk() { | 
					
						
							|  |  |  |     create_common_build_mk $@ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cat <<'EOF' >> mk/build.mk | 
					
						
							|  |  |  | LLFLAGS		= -shared -Wl,-soname=$(SONAME) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 00:36:23 -04:00
										 |  |  | STATIC		= lib$(LIBNAME).a | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 16:45:03 +00:00
										 |  |  | SONAME_SHORT	= lib$(LIBNAME).so | 
					
						
							|  |  |  | SONAME		= $(SONAME_SHORT).$(VERSION_MAJOR) | 
					
						
							|  |  |  | SONAME_FULL	= $(SONAME_SHORT).$(VERSION) | 
					
						
							| 
									
										
										
										
											2020-07-03 00:36:23 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cat <<EOF >> mk/build.mk | 
					
						
							|  |  |  | PREFIX      = $PREFIX | 
					
						
							| 
									
										
										
										
											2015-07-14 16:45:03 +00:00
										 |  |  | EOF | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | create_darwin_build_mk() { | 
					
						
							|  |  |  |     create_common_build_mk $@ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cat <<'EOF' >> mk/build.mk | 
					
						
							|  |  |  | LLFLAGS		= -dynamiclib -current_version $(VERSION) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | STATIC      = lib$(LIBNAME).a | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 00:36:23 -04:00
										 |  |  | SONAME_SHORT	= lib$(LIBNAME).dylib | 
					
						
							| 
									
										
										
										
											2015-07-14 16:45:03 +00:00
										 |  |  | SONAME		= lib$(LIBNAME).$(VERSION_MAJOR).dylib | 
					
						
							|  |  |  | SONAME_FULL	= lib$(LIBNAME).$(VERSION).dylib | 
					
						
							| 
									
										
										
										
											2020-07-03 00:36:23 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cat <<EOF >> mk/build.mk | 
					
						
							|  |  |  | PREFIX      = $PREFIX | 
					
						
							| 
									
										
										
										
											2015-07-14 16:45:03 +00:00
										 |  |  | EOF | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | for arg in $@; do | 
					
						
							|  |  |  |     case $arg in | 
					
						
							|  |  |  |         "--enable-debug") | 
					
						
							|  |  |  |             DEBUG=1 | 
					
						
							|  |  |  |         ;; | 
					
						
							|  |  |  |     esac | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ ! -d "mk" ]; then | 
					
						
							|  |  |  |     mkdir -m 0755 mk | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | case $OS in | 
					
						
							|  |  |  |     Linux) | 
					
						
							|  |  |  |         create_linux_config_h | 
					
						
							|  |  |  | 		create_linux_build_mk | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Darwin) | 
					
						
							|  |  |  |         create_darwin_config_h | 
					
						
							|  |  |  | 		create_darwin_build_mk | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  | esac |