|
1 | | -# standard amuse configuration include |
2 | | -# config.mk will be made after ./configure has run |
3 | | -ifeq ($(origin AMUSE_DIR), undefined) |
4 | | - AMUSE_DIR := $(shell amusifier --get-amuse-dir) |
| 1 | +ifneq (,$(filter-out clean distclean, $(MAKECMDGOALS))) |
| 2 | +include support/config.mk |
5 | 3 | endif |
6 | | --include $(AMUSE_DIR)/config.mk |
7 | 4 |
|
8 | | -MPICXX ?= mpicxx |
9 | | -export MPICXX |
10 | 5 |
|
| 6 | +# Detecting dependencies |
| 7 | +support/config.mk: |
| 8 | + cd support && ./configure |
11 | 9 |
|
12 | | -SRCDIR = src |
13 | | -OBJDIR = $(SRCDIR)/obj |
14 | | -APP = $(SRCDIR)/bin/SimpleX |
15 | | -PLUGINS = $(SRCDIR)/plugins |
16 | 10 |
|
17 | | -OBJS = $(OBJDIR)/amuse_interface.o $(OBJDIR)/SimpleX.o \ |
18 | | - $(OBJDIR)/Structs.o $(OBJDIR)/rates.o $(OBJDIR)/Common.o $(OBJDIR)/h5w_serial.o \ |
19 | | - $(OBJDIR)/keyValue.o $(OBJDIR)/tree_structures.o $(OBJDIR)/hilbert.o |
| 11 | +# Building the code into a static library |
| 12 | +DEPFLAGS += $(GSL_FLAGS) $(HDF5_CFLAGS) $(HEALPIX_CXX_CFLAGS) $(QHULL_FLAGS) |
20 | 13 |
|
21 | | -GLOBJS = $(OBJDIR)/amuse_interface_gl.o |
| 14 | +CFLAGS += $(DEPFLAGS) |
22 | 15 |
|
23 | | -HEALPIX_PATH = $(PLUGINS)/HEALPix/ |
24 | | -QHULL_PATH = $(PLUGINS)/qhull-2012.1/ |
| 16 | +LDFLAGS += $(HDF5_LDFLAGS) |
25 | 17 |
|
26 | | -HDF5_FLAGS ?= -I$(HDF5_PATH)/include |
27 | | -HDF5_LIBS ?= -L$(HDF5_PATH)/lib -lhdf5 -lz |
| 18 | +LDLIBS += $(GSL_LIBS) $(HDF5_LIBS) $(HEALPIX_CXX_LIBS) $(QHULL_LIBS) |
28 | 19 |
|
29 | | -GSL_PATH = /usr/local/scisoft |
| 20 | +CODELIB = libsimplex.a |
30 | 21 |
|
31 | | -# here we use ?= to allow amuse configure to override these |
32 | | -# variables |
33 | | -GSL_FLAGS ?= -I$(GSL_PATH)/include |
34 | | -GSL_LIBS ?= -L$(GSL_PATH)/lib -lgsl -lgslcblas |
| 22 | +CODEOBJS = amuse_interface.o SimpleX.o Structs.o rates.o Common.o h5w_serial.o |
| 23 | +CODEOBJS += keyValue.o tree_structures.o hilbert.o |
| 24 | +CODEOBJS := $(patsubst %,src/obj/%,$(CODEOBJS)) |
35 | 25 |
|
36 | | -LIBS = $(HDF5_LIBS) \ |
37 | | - $(GSL_LIBS) \ |
38 | | - -L$(QHULL_PATH)/lib -lqhullstatic \ |
39 | | - -L$(HEALPIX_PATH)/lib -lhealpix_cxx |
| 26 | +.PHONY: $(CODELIB) |
| 27 | +$(CODELIB): |
| 28 | + $(MAKE) -C src amuse MPICXX=$(MPICXX) HDF5_FLAGS="$(HDF5_CFLAGS) $(HDF5_CPPFLAGS)" HDF5_LIBS="$(HDF5_LDFLAGS) $(HDF5_LIBS)" |
| 29 | + $(AR) ruv $@ $(CODEOBJS) |
| 30 | + $(RANLIB) $@ |
40 | 31 |
|
41 | | -GLINCLUDE = -I/usr/include/GL -I$(GL_PATH)/include/GL/ |
42 | | -GLLIB = -L$(GL_PATH)/lib -lf90GLU -lf90GL -lf90glut -lGLU -lGL -lglut #-lguide |
43 | | -GLLIBS= $(GLLIB) -lGL -lGLU -L/home/inti/libraries/freeglut-2.4.0/src/.libs -lglut \ |
44 | | --L/usr/X11R6/lib -lXaw -lXt -lXmu -lXi -lXext -lX11 -ltiff |
45 | 32 |
|
46 | | -all: compile simplex_worker |
| 33 | +# Building the workers |
| 34 | +simplex_worker.h: interface.py |
| 35 | + amusifier --type=h interface.py SimpleXInterface -o $@ |
47 | 36 |
|
48 | | -compile: $(APP) |
| 37 | +simplex_worker.cc: interface.py |
| 38 | + amusifier --type=c interface.py SimpleXInterface -o $@ |
49 | 39 |
|
50 | | -$(APP): |
51 | | - cd $(SRCDIR) && $(MAKE) CC="$(CC) $(CFLAGS)" CXX="$(CXX) $(CXXFLAGS)" |
| 40 | +simplex_worker.o: simplex_worker.cc simplex_worker.h |
| 41 | + $(MPICXX) -c -o $@ $(CFLAGS) $< |
52 | 42 |
|
53 | | -clean: |
54 | | - $(RM) *.so *.o *.pyc worker.cc worker.h worker_gl.cc worker_gl.h |
55 | | - $(RM) worker_code.cc worker_code.h worker_code_gl.cc worker_code_gl.h |
56 | | - $(RM) simplex_worker simplex_worker_gl *~ |
57 | | - cd $(SRCDIR) && $(MAKE) clean |
| 43 | +simplex_worker: simplex_worker.o $(CODELIB) |
| 44 | + $(MPICXX) -o $@ $(LDFLAGS) $^ $(LDLIBS) |
| 45 | + |
| 46 | + |
| 47 | +# Which packages contain which workers? |
| 48 | +amuse-simplex_contains: simplex_worker |
58 | 49 |
|
59 | | -distclean: clean |
60 | | - cd $(SRCDIR) && $(MAKE) veryclean |
61 | | - |
62 | | -worker_code.cc: interface.py |
63 | | - $(CODE_GENERATOR) --type=c $< SimpleXInterface -o $@ |
64 | 50 |
|
65 | | -worker_code.h: interface.py |
66 | | - $(CODE_GENERATOR) --type=h $< SimpleXInterface -o $@ |
| 51 | +# Building and installing packages |
| 52 | +develop-%: %_contains |
| 53 | + support/shared/uninstall.sh $* |
| 54 | + python -m pip install -e packages/$* |
67 | 55 |
|
68 | | -worker_code-gl.cc: interface.py |
69 | | - $(CODE_GENERATOR) --type=c $< GlSimpleXInterface -o $@ |
| 56 | +install-%: %_contains |
| 57 | + support/shared/uninstall.sh $* |
| 58 | + python -m pip install packages/$* |
70 | 59 |
|
71 | | -worker_code-gl.h: interface.py |
72 | | - $(CODE_GENERATOR) --type=h $< GlSimpleXInterface -o $@ |
| 60 | +package-%: %_contains |
| 61 | + python3 -m pip install -vv --no-cache-dir --no-deps --no-build-isolation --prefix ${PREFIX} packages/$* |
73 | 62 |
|
74 | | -simplex_worker: worker_code.cc worker_code.h $(OBJS) |
75 | | - $(MPICXX) $(LDFLAGS) $< $(OBJS) -o $@ $(LIBS) |
| 63 | +test-%: |
| 64 | + cd packages/$* && pytest |
76 | 65 |
|
77 | | -#simplex_worker_gl: worker_code-gl.cc worker_code-gl.h $(OBJS) $(GLOBJS) |
78 | | -# $(MPICXX) $^ -o $@ $(LIBS) $(GLLIBS) |
79 | 66 |
|
80 | | -$(OBJDIR)/amuse_interface.o: $(SRCDIR)/src/amuse_interface.cpp $(SRCDIR)/src/amuse_interface.h |
81 | | - cd $(SRCDIR) && $(MAKE) amuse_interface |
82 | | - |
83 | | -$(OBJDIR)/amuse_interface_gl.o: $(SRCDIR)/src/amuse_interface_gl.cpp |
84 | | - cd $(SRCDIR) && $(MAKE) amuse_interface_gl |
| 67 | +# Cleaning up |
| 68 | +.PHONY: clean |
| 69 | +clean: |
| 70 | + $(MAKE) -C src clean |
| 71 | + rm -rf *.o *worker* |
| 72 | + |
| 73 | +.PHONY: distclean |
| 74 | +distclean: clean |
| 75 | + rm -f support/config.mk support/config.log support/config.status |
| 76 | + rm -rf support/autom4te.cache |
0 commit comments