summaryrefslogtreecommitdiff
path: root/config.mk
blob: 45fab9695c8504c0123f5449edc83b4f2897bc7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# 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 and FreeBSD configuration

ifneq ($(findstring $(shell uname), Linux, FreeBSD), )

OS 	:= -DLC_LINUX
OSDIR 	:= linux
PREFIX  := /usr/local

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 "" >> $(OSDIR)/config.h

### 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 -rf 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 -rf ztest.c ztest

### Check if the user has libjpeg 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 -rf pngtest.c pngtest

	@echo "" >> $(OSDIR)/config.h
	@echo "#endif // _CONFIG_H_" >> $(OSDIR)/config.h