1AUTOMAKE_OPTIONS=foreign
2ACLOCAL_AMFLAGS= -I m4 --install
3
4BOOTSTRAP_OPTIONS =
5
6if INTINFISINT
7POLYIMPORT_OPTIONS = --intIsIntInf
8else
9POLYIMPORT_OPTIONS =
10endif
11
12DIST_SUBDIRS = libpolyml libpolymain modules
13
14SUBDIRS = libpolyml libpolymain . modules
15
16bin_PROGRAMS = polyimport poly
17
18dist_bin_SCRIPTS = polyc
19
20man_MANS = poly.1 polyimport.1 polyc.1
21
22# Select the architecture-specific pre-built compiler
23if ARCHI386
24POLYIMPORT = $(srcdir)/imports/polymli386.txt
25else
26if ARCHINTERPRET
27POLYIMPORT = $(srcdir)/imports/polymlint.txt
28else
29if ARCHINTERPRET64
30POLYIMPORT = $(srcdir)/imports/polymlint64.txt
31else
32if ARCHX86_64
33if WINDOWS64CALLS
34POLYIMPORT = $(srcdir)/imports/polymlx86_64win.txt
35else
36POLYIMPORT = $(srcdir)/imports/polymlx86_64sysv.txt
37endif
38else
39endif
40endif
41endif
42endif
43
44noinst_HEADERS = polyexports.h
45
46poly_LDFLAGS=
47polyimport_LDFLAGS=
48POLYRESOURCES=
49EXTRALDFLAGS=
50
51if NATIVE_WINDOWS
52if ARCHINTERPRET64
53EXTRALDFLAGS += -Wl,-u,WinMain
54else
55if ARCHX86_64
56EXTRALDFLAGS += -Wl,-u,WinMain
57else
58EXTRALDFLAGS += -Wl,-u,_WinMain@16 -Wl,--large-address-aware
59endif
60endif
61
62if WINDOWSGUI
63EXTRALDFLAGS += -mwindows
64polyimport_LDFLAGS += -mwindows
65else
66EXTRALDFLAGS += -mconsole
67polyimport_LDFLAGS += -mconsole
68endif
69
70poly_LDFLAGS += $(EXTRALDFLAGS)
71
72POLYOBJECTFILE = polyexport.obj
73POLYRESOURCES += polyresource.o
74OBJECTSUFFIX=obj
75else
76POLYOBJECTFILE = polyexport.o
77OBJECTSUFFIX=o
78endif
79
80if MACOSLDOPTS
81poly_LDFLAGS += -Wl,-no_pie
82endif
83
84poly_SOURCES = 
85poly_LDADD = $(POLYOBJECTFILE) $(POLYRESOURCES) libpolymain/libpolymain.la libpolyml/libpolyml.la 
86
87polyimport_SOURCES = polyimport.c
88polyimport_LDADD = $(POLYRESOURCES) libpolyml/libpolyml.la
89
90EXTRA_DIST = \
91	imports/polymli386.txt \
92	imports/polymlint64.txt \
93	imports/polymlint.txt \
94	imports/polymlx86_64.txt \
95	libpolyml/x86asm.asm \
96	exportPoly.sml \
97	poly.1 \
98	polyimport.1
99
100dist-hook:
101	find {basis,mlsource}/ -type d -exec mkdir $(distdir)/{} \;
102	find {basis,mlsource}/ -type f -not -name .svn \
103	    -exec cp -pf {} $(distdir)/{} \;
104
105
106
107# Unix.
108polyexport.o: polyimport exportPoly.sml polytemp.txt
109	./polyimport $(POLYIMPORT_OPTIONS) polytemp.txt -I $(srcdir) < $(srcdir)/exportPoly.sml
110
111# Windows.  When building on Windows make sure that we provide both stdin and stdout to suppress the GUI.
112polyexport.obj: polyimport$(EXEEXT) exportPoly.sml polytemp.txt
113	./polyimport $(POLYIMPORT_OPTIONS) polytemp.txt -I $(srcdir) < $(srcdir)/exportPoly.sml | cat
114
115polyresource.o: PolyML.rc poly.ico
116	$(WINDRES) -o polyresource.o $(srcdir)/PolyML.rc
117
118polytemp.txt: $(POLYIMPORT)
119	cp $(POLYIMPORT) polytemp.txt
120
121#polyc: buildpolyc
122#	./buildpolyc LINK=\"$(CC)\" BINDIR=\"$(bindir)\" LIBDIR=\"$(libdir)\" LIBS=\"$(LIBS)\" EXTRALDFLAGS=\"$(EXTRALDFLAGS)\" SUFFIX=\"$(OBJECTSUFFIX)\"
123
124# This builds the compiler but does not update the files in the imports directory.
125# It then builds a version of poly containing the new compiler.
126compiler: all
127	./poly $(BOOTSTRAP_OPTIONS) --error-exit < mlsource/BuildExport.sml
128	$(MAKE)
129
130reboot: compiler
131	cp polytemp.txt $(POLYIMPORT)
132
133clean-local:
134	rm -f *.obj polytemp.txt polyc
135
136# Run tests
137check-local: all
138	echo "val () = use \"$(srcdir)/Tests/RunTests\"; val () = OS.Process.exit(if runTests \"$(srcdir)/Tests\" then OS.Process.success else OS.Process.failure):unit;" | ./poly
139
140# Retain this target for backwards compatibility
141tests: check
142