# LeoCAD configuration file # include version.mk default: all CC := gcc CXX := g++ # (Add a -g for debugging) CPPFLAGS += -O2 -Wall # Add compile options, such as -I option to include jpeglib's headers # CPPFLAGS += -I/home/fred/jpeglib # Add linker options, such as -L option to include jpeglib's libraries # LDFLAGS += -L/home/fred/jpeglib ### Linux configuration ifeq ($(shell uname), Linux) OS := -DLC_LINUX OSDIR := linux PREFIX := /usr/local GTK_CONFIG := gtk-config endif ### FreeBSD configuration ifeq ($(shell uname), FreeBSD) OS := -DLC_LINUX OSDIR := linux PREFIX := /usr/local GTK_CONFIG := gtk12-config CPPFLAGS += -L/usr/local/lib endif ### BeOS configuration ifeq ($(shell uname), BeOS) OS := -DLC_BEOS OSDIR := beos endif .PHONY: config ### Automatic configuration config: @echo "Automatic configuration" @echo "### LeoCAD configuration" > $(OSDIR)/config.mk @echo "### Auto-generated file, DO NOT EDIT" >> $(OSDIR)/config.mk @echo "" >> $(OSDIR)/config.mk @echo "//" > $(OSDIR)/config.h @echo "// LeoCAD configuration" >> $(OSDIR)/config.h @echo "//" >> $(OSDIR)/config.h @echo "// Auto-generated file, DO NOT EDIT" >> $(OSDIR)/config.h @echo "//" >> $(OSDIR)/config.h @echo "" >> $(OSDIR)/config.h @echo "#ifndef _CONFIG_H_" >> $(OSDIR)/config.h @echo "#define _CONFIG_H_" >> $(OSDIR)/config.h @echo "" >> $(OSDIR)/config.h ### Version information @echo "#define LC_VERSION_MAJOR $(MAJOR)" >> $(OSDIR)/config.h @echo "#define LC_VERSION_MINOR $(MINOR)" >> $(OSDIR)/config.h @echo "#define LC_VERSION_PATCH $(PATCHLVL)" >> $(OSDIR)/config.h @echo "#define LC_VERSION_OSNAME \"$(shell uname)\"" >> $(OSDIR)/config.h @echo "#define LC_VERSION \"$(MAJOR).$(MINOR).$(PATCHLVL)\"" >> $(OSDIR)/config.h @echo "#define LC_INSTALL_PREFIX \"$(PREFIX)\"" >> $(OSDIR)/config.h @echo "" >> $(OSDIR)/config.h ### Determine if machine is little or big endian @echo -n "Determining endianess... " @echo "main () { union { long l; char c[sizeof (long)]; } u;" > endiantest.c @echo "u.l = 1; exit (u.c[sizeof (long) - 1] == 1); }" >> endiantest.c @if { (eval $(CC) endiantest.c -o endiantest) 2> /dev/null; } && \ (test -s endiantest && (./endiantest; exit) 2> /dev/null); then \ echo "little endian"; \ echo "#define LC_LITTLE_ENDIAN" >> $(OSDIR)/config.h; \ else \ echo "big endian"; \ echo "#define LC_BIG_ENDIAN" >> $(OSDIR)/config.h; \ fi @rm -f endiantest.c endiantest ### Check if the user has libjpeg installed @echo -n "Checking for jpeg support... " @echo "char jpeg_read_header();" > jpegtest.c @echo "int main() { jpeg_read_header(); return 0; }" >> jpegtest.c @if { (eval $(CC) jpegtest.c -ljpeg -o jpegtest $(CPPFLAGS) $(LDFLAGS)) 2> /dev/null; } && \ (test -s jpegtest); then \ echo "ok"; \ echo "HAVE_JPEGLIB = yes" >> $(OSDIR)/config.mk; \ echo "#define LC_HAVE_JPEGLIB" >> $(OSDIR)/config.h; \ else \ echo "no (libjpeg required)"; \ echo "HAVE_JPEGLIB = no" >> $(OSDIR)/config.mk; \ echo "#undef LC_HAVE_JPEGLIB" >> $(OSDIR)/config.h; \ fi @rm -f jpegtest.c jpegtest ### Check if the user has zlib installed @echo -n "Checking for zlib support... " @echo "char gzread();" > ztest.c @echo "int main() { gzread(); return 0; }" >> ztest.c @if { (eval $(CC) ztest.c -lz -o ztest $(CPPFLAGS) $(LDFLAGS)) 2> /dev/null; } && \ (test -s ztest); then \ echo "ok"; \ echo "HAVE_ZLIB = yes" >> $(OSDIR)/config.mk; \ echo "#define LC_HAVE_ZLIB" >> $(OSDIR)/config.h; \ else \ echo "no (zlib required)"; \ echo "HAVE_ZLIB = no" >> $(OSDIR)/config.mk; \ echo "#undef LC_HAVE_ZLIB" >> $(OSDIR)/config.h; \ fi @rm -f ztest.c ztest ### Check if the user has libpng installed @echo -n "Checking for png support... " @echo "char png_read_info();" > pngtest.c @echo "int main() { png_read_info(); return 0; }" >> pngtest.c @if { (eval $(CC) pngtest.c -lpng -o pngtest $(CPPFLAGS) $(LDFLAGS)) 2> /dev/null; } && \ (test -s pngtest); then \ echo "ok"; \ echo "HAVE_PNGLIB = yes" >> $(OSDIR)/config.mk; \ echo "#define LC_HAVE_PNGLIB" >> $(OSDIR)/config.h; \ else \ echo "no (libpng required)"; \ echo "HAVE_PNGLIB = no" >> $(OSDIR)/config.mk; \ echo "#undef LC_HAVE_PNGLIB" >> $(OSDIR)/config.h; \ fi @rm -f pngtest.c pngtest @echo "" >> $(OSDIR)/config.h @echo "#endif // _CONFIG_H_" >> $(OSDIR)/config.h