From fc4da362e3f2013b849b1f31076c85360f89ace5 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Wed, 18 Jan 2017 15:18:55 -0600 Subject: [PATCH 1/3] Change makefile for IRPF90 v2 --- src/Makefile | 74 +++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/src/Makefile b/src/Makefile index 91f9ae6..3eef85d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,55 +1,45 @@ -# EZFIO is an automatic generator of I/O libraries -# Copyright (C) 2009 Anthony SCEMAMA, CNRS -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Anthony Scemama -# LCPQ - IRSAMC - CNRS -# Universite Paul Sabatier -# 118, route de Narbonne -# 31062 Toulouse Cedex 4 -# scemama@irsamc.ups-tlse.fr +IRPF90= python ~/Work/Project/p16.03/irpf90/src/irpf90.py +IRPF90FLAGS= -I ./ +BUILD_SYSTEM= make -DEFAULT_TARGET: all +export LD_LIBARY_PATH = +export CXX = g++ +export CXXFLAGS = -O2 +export CC = gcc +export FC = gfortran +export CFLAGS = -O2 +export FCFLAGS = -O2 +export AR = AR +export RANLIB = ranlib -include ../make.config -export +ifeq ($(BUILD_SYSTEM),ninja) + CMD_PHONY=-t # Chose a specific target + BUILD_FILE=IRPF90_temp/build.ninja + IRPF90FLAGS += -j # Create ninja +else + CMD_PHONY= -j # All job abalaible + BUILD_FILE=IRPF90_temp/build.make +endif -include irpf90.make - -irpf90.make: $(wildcard *.irp.f) ../config/* - $(IRPF90) - -include ../version +mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) +current_dir := $(dir $(mkfile_path)) .PHONY: static all +export PYTHONPATH:=$(current_dir):$(PYTHONPATH) + all: static ../Python/ezfio.py ../Ocaml/ezfio.ml static: ../lib/libezfio.a ../lib/libezfio_irp.a ../lib/libezfio.a: IRPF90_temp/irpf90.a rm -f ../lib/libezfio.a - $(AR) cru ../lib/libezfio.a $(OBJ1) + cp IRPF90_temp/irpf90.a ../lib/libezfio.a $(RANLIB) ../lib/libezfio.a + ../lib/libezfio_irp.a: ../lib/libezfio.a - rm -f ../lib/libezfio_irp.a cp ../lib/libezfio.a ../lib/libezfio_irp.a - $(AR) dv ../lib/libezfio_irp.a irp_stack.irp.o - $(RANLIB) ../lib/libezfio_irp.a ../Python/ezfio.py: python create_python.py @@ -57,4 +47,16 @@ static: ../lib/libezfio.a ../lib/libezfio_irp.a ../Ocaml/ezfio.ml: python create_ocaml.py +IRPF90_temp/irpf90.a: $(BUILD_FILE) + $(BUILD_SYSTEM) -C $(dir $^) -f $(notdir $^) $(CMD_PHONY) $(current_dir)$@ && touch $@ +$(BUILD_FILE): $(shell find . -path ./IRPF90_temp -prune -o -name '*.irp.f' -maxdepth 2 -print) + $(IRPF90) $(IRPF90FLAGS) + +clean: $(BUILD_FILE) + $(BUILD_SYSTEM) -f $^ $(CMD_PHONY) clean + rm -f $(BUILD_FILE) + rm -f ../lib/libezfio.a ../lib/libezfio_irp.a + +veryclean: clean + rm -rf IRPF90_temp/ IRPF90_man/ irpf90_entities dist tags $(EXE) From 6d2c2f13a07f3b587fb5df9eb79e30f72a539ced Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Jan 2017 08:28:28 -0600 Subject: [PATCH 2/3] Corrected makefile --- src/Makefile | 67 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/src/Makefile b/src/Makefile index 3eef85d..75af455 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,35 +1,47 @@ -IRPF90= python ~/Work/Project/p16.03/irpf90/src/irpf90.py -IRPF90FLAGS= -I ./ BUILD_SYSTEM= make -export LD_LIBARY_PATH = -export CXX = g++ -export CXXFLAGS = -O2 -export CC = gcc -export FC = gfortran -export CFLAGS = -O2 -export FCFLAGS = -O2 -export AR = AR -export RANLIB = ranlib +.EXPORT_ALL_VARIABLES: +include ../make.config + +# Dark magic below modify with caution! +# "You are Not Expected to Understand This" +# . +# /^\ . +# /\ "V", +# /__\ I O o +# //..\\ I . +# \].`[/ I +# /l\/j\ (] . O +# /. ~~ ,\/I . +# \\L__j^\/I o +# \/--v} I o . +# | | I _________ +# | | I c(` ')o +# | l I \. ,/ +# _/j L l\_! _//^---^\\_ + ifeq ($(BUILD_SYSTEM),ninja) - CMD_PHONY=-t # Chose a specific target BUILD_FILE=IRPF90_temp/build.ninja - IRPF90FLAGS += -j # Create ninja -else - CMD_PHONY= -j # All job abalaible + IRPF90FLAGS += -j +else ifeq ($(BUILD_SYSTEM),make) BUILD_FILE=IRPF90_temp/build.make + BUILD_SYSTEM += -j +else +DUMMY: + $(error 'Wrong BUILD_SYSTEM: $(BUILD_SYSTEM)') endif -mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) -current_dir := $(dir $(mkfile_path)) +define run_and_touch + $(BUILD_SYSTEM) -C $(dir $(1) ) -f $(notdir $(1) ) $(addprefix $(CURDIR)/, $(2)) && touch $(2) +endef + +export PYTHONPATH:=$(CURDIR):$(PYTHONPATH) + .PHONY: static all -export PYTHONPATH:=$(current_dir):$(PYTHONPATH) - all: static ../Python/ezfio.py ../Ocaml/ezfio.ml - static: ../lib/libezfio.a ../lib/libezfio_irp.a ../lib/libezfio.a: IRPF90_temp/irpf90.a @@ -37,7 +49,7 @@ static: ../lib/libezfio.a ../lib/libezfio_irp.a cp IRPF90_temp/irpf90.a ../lib/libezfio.a $(RANLIB) ../lib/libezfio.a - +#No more irp_stack ../lib/libezfio_irp.a: ../lib/libezfio.a cp ../lib/libezfio.a ../lib/libezfio_irp.a @@ -48,15 +60,14 @@ static: ../lib/libezfio.a ../lib/libezfio_irp.a python create_ocaml.py IRPF90_temp/irpf90.a: $(BUILD_FILE) - $(BUILD_SYSTEM) -C $(dir $^) -f $(notdir $^) $(CMD_PHONY) $(current_dir)$@ && touch $@ + $(call run_and_touch, $<, $@) -$(BUILD_FILE): $(shell find . -path ./IRPF90_temp -prune -o -name '*.irp.f' -maxdepth 2 -print) +$(BUILD_FILE): $(shell find . -maxdepth 2 -path ./IRPF90_temp -prune -o -name '*.irp.f' -print) ../config/* $(IRPF90) $(IRPF90FLAGS) -clean: $(BUILD_FILE) - $(BUILD_SYSTEM) -f $^ $(CMD_PHONY) clean - rm -f $(BUILD_FILE) - rm -f ../lib/libezfio.a ../lib/libezfio_irp.a +clean: + rm -f -- $(BUILD_FILE) $(shell find IRPF90_temp -type f \( -name "*.o" -o -name "*.mod" -name "*.a" \) -delete;) + rm -f ../lib/libezfio.a ../lib/libezfio_irp.a veryclean: clean - rm -rf IRPF90_temp/ IRPF90_man/ irpf90_entities dist tags $(EXE) + rm -rf IRPF90_temp/ IRPF90_man/ irpf90_entities dist tags From 11729146547052b7a0ed704a918d7b08e07cf657 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Jan 2017 08:37:19 -0600 Subject: [PATCH 3/3] Fix configure --- configure.py | 7 +++---- src/Makefile | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/configure.py b/configure.py index 86e8773..0f86bb3 100755 --- a/configure.py +++ b/configure.py @@ -26,7 +26,7 @@ d_default = { "FCFLAGS" : '-O2', "RANLIB" : 'ranlib', "AR" : 'ar', - "NINJA" : 'ninja', + "BUILD_SYSTEM" : 'make' } CONFIG_FILES=' '.join([ os.path.join("config",x) for x in os.listdir('config') if x != '.empty']) @@ -112,7 +112,7 @@ rule build_libezfio_a description = Building libezfio.a rule build_libezfio_irp_a - command = cp lib/libezfio.a lib/libezfio_irp.a ; {AR} dv lib/libezfio_irp.a irp_stack.irp.o > /dev/null ; {RANLIB} lib/libezfio_irp.a + command = cp lib/libezfio.a lib/libezfio_irp.a ; {RANLIB} lib/libezfio_irp.a description = Building libezfio_irp.a rule build_python @@ -141,5 +141,4 @@ build Ocaml/ezfio.ml: build_ocaml | lib/libezfio.a if __name__ == '__main__': - - create_build_ninja() + create_build_ninja() diff --git a/src/Makefile b/src/Makefile index 75af455..66cdeb5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,3 @@ -BUILD_SYSTEM= make - .EXPORT_ALL_VARIABLES: include ../make.config @@ -53,10 +51,10 @@ static: ../lib/libezfio.a ../lib/libezfio_irp.a ../lib/libezfio_irp.a: ../lib/libezfio.a cp ../lib/libezfio.a ../lib/libezfio_irp.a -../Python/ezfio.py: +../Python/ezfio.py: ../lib/libezfio.a python create_python.py -../Ocaml/ezfio.ml: +../Ocaml/ezfio.ml: ../lib/libezfio.a python create_ocaml.py IRPF90_temp/irpf90.a: $(BUILD_FILE)