Replace AR by ARCHIVE

This commit is contained in:
Anthony Scemama 2020-12-06 20:48:35 +01:00
parent da3ee8864a
commit 2027274583
2 changed files with 46 additions and 38 deletions

View File

@ -36,9 +36,9 @@ FILENAME_GITIGNORE = ".gitignore"
IRPF90_MAKE = "irpf90.make"
if sys.platform in ["linux", "linux2"]:
AR = "ar crs"
ARCHIVE = "ar crs"
elif sys.platform == "darwin":
AR = "libtool -static -o"
ARCHIVE = "libtool -static -o"
else:
print("Unknown platform. Only Linux and Darwin are supported.")
sys.exit(-1)
@ -58,7 +58,7 @@ def create():
FC = gfortran
FCFLAGS= -O2 -ffree-line-length-none -I .
NINJA = ninja
AR = %s
ARCHIVE= %s
RANLIB = ranlib
SRC=
@ -70,7 +70,7 @@ export
%s: $(filter-out %s%%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile
\t$(IRPF90)
"""%(AR,IRPF90_MAKE,IRPF90_MAKE,irpdir)
"""%(ARCHIVE,IRPF90_MAKE,IRPF90_MAKE,irpdir)
file.write(t)
file.close()
create_gitignore()
@ -197,7 +197,7 @@ def run_make():
print(dir+"%.o: %.F\n\t$(FC) $(FCFLAGS) -c $*.F -o "+dir+"$*.o", file=file)
print(dir+"%.irp.F90: "+IRPF90_MAKE+"\n", file=file)
print("move:\n\t@mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING=\n", file=file)
print("IRPF90_temp/irpf90.a: $(OBJ) $(OBJ1)\n\t$(AR) IRPF90_temp/irpf90.a $(OBJ1)\n", file=file)
print("IRPF90_temp/irpf90.a: $(OBJ) $(OBJ1)\n\t$(ARCHIVE) IRPF90_temp/irpf90.a $(OBJ1)\n", file=file)
print("clean:\n\trm -rf $(EXE) $(OBJ1) IRPF90_temp/irpf90.a $(ALL_OBJ1) $(ALL)\n", file=file)
print("veryclean:\n\t- $(MAKE) clean\n", file=file)
print("\t- rm -rf "+irpdir+" "+mandir+" "+IRPF90_MAKE+" irpf90_entities dist tags\n", file=file)

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
# Copyright (C) 2009 Anthony SCEMAMA
#
# 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
@ -20,8 +20,8 @@
# Anthony Scemama
# LCPQ - IRSAMC - CNRS
# Universite Paul Sabatier
# 118, route de Narbonne
# 31062 Toulouse Cedex 4
# 118, route de Narbonne
# 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr
@ -39,6 +39,14 @@ cwd = os.getcwd()
PRINT_WIDTH=50
if sys.platform in ["linux", "linux2"]:
AR = "ar crs"
elif sys.platform == "darwin":
AR = "libtool -static -o"
else:
print("Unknown platform. Only Linux and Darwin are supported.")
sys.exit(-1)
def dress(f,in_root=False):
"""
Transfoms the filename f into $PWD/IRPF90_temp/f
@ -68,7 +76,7 @@ def create_build_touches(list_of_other_o):
list_of_modules = ' '.join(list_of_modules)
result = '\n'.join(
[
[
"build {target_o}: compile_touches_{id} {target_F90} | {list_of_modules}",
" short_in = {short_target_F90}",
" short_out = {short_target_o}",
@ -86,7 +94,7 @@ def create_build_touches(list_of_other_o):
short_target_F90 = os.path.split(target_F90)[1] ,
short_target_o = os.path.split(target_o)[1] ,
target_F90 = target_F90 ,
target_o = target_o
target_o = target_o
)
return result
@ -110,7 +118,7 @@ def create_build_target(t,list_of_other_o):
needed_modules = [ "%s.irp.module.o"%(modules[x].filename) for x in modules \
if modules[x].name in t.needed_modules ] + [ target_module_o ]
list_of_o = [ target_o, target_module_o, irp_lib ]
list_of_o = [ target_o, target_module_o, irp_lib ]
list_of_o = ' '.join(list_of_o)
list_of_modules = list(map(dress, needed_modules)) + list_of_other_o
@ -119,7 +127,7 @@ def create_build_target(t,list_of_other_o):
list_of_includes = ' '.join([dress(x,in_root=True) for x in t.includes])
result = '\n'.join(
[ "build {target}: link_{id} {list_of_o}",
[ "build {target}: link_{id} {list_of_o}",
" short_out = {short_target}",
"",
"build {target_o}: compile_fortran_{id} {target_F90} | {list_of_modules} {list_of_includes}",
@ -146,7 +154,7 @@ def create_build_target(t,list_of_other_o):
target_module_F90 = target_module_F90 ,
target_module_o = target_module_o ,
target_o = target_o ,
target = target
target = target
)
return result
@ -176,7 +184,7 @@ def create_build_non_target(t,list_of_other_o):
list_of_includes = ' '.join([dress(x,in_root=True) for x in t.includes])
result = '\n'.join(
[
[
"build {target_o}: compile_fortran_{id} {target_F90} | {list_of_modules} {list_of_externals}",
" short_in = {short_target_F90}",
" short_out = {short_target}",
@ -198,7 +206,7 @@ def create_build_non_target(t,list_of_other_o):
target_F90 = target_F90 ,
target_module_F90 = target_module_F90 ,
target_module_o = target_module_o ,
target_o = target_o
target_o = target_o
)
return result
@ -222,7 +230,7 @@ def create_build_remaining(f):
elif extension.lower() in [ 'cxx', 'cpp' ]:
result = [ "build {target_o}: compile_cxx_{id} {target_i}" ]
result += [ " short_in = {short_target_i}",
result += [ " short_in = {short_target_i}",
" short_out = {short_target_o}", "" ]
result = '\n'.join(result).format(
target_o = target_o,
@ -246,7 +254,7 @@ TARGETS={1}
all:
$(NINJA)
$(TARGETS):
$(TARGETS):
$(NINJA) $(PWD)/$@
clean:
@ -271,8 +279,8 @@ def run():
try: FC = os.environ["FC"]
except KeyError: FC="gfortran -ffree-line-length-none"
try: AR = os.environ["AR"]
except KeyError: AR="ar crs"
try: ARCHIVE = os.environ["ARCHIVE"]
except KeyError: ARCHIVE=AR
try: CC = os.environ["CC"]
except KeyError: CC="gcc"
@ -285,7 +293,7 @@ def run():
FC += " "+' '.join(includes)
CC += " "+' '.join(includes)
CXX += " "+' '.join(includes)
try: SRC = os.environ["SRC"].split()
except KeyError: SRC=[]
@ -311,32 +319,32 @@ def run():
# Rules
t = [ "rule compile_fortran_{id}",
" command = {FC} {FCFLAGS} -c $in -o $out",
" description = F : $short_in -> $short_out",
t = [ "rule compile_fortran_{id}",
" command = {FC} {FCFLAGS} -c $in -o $out",
" description = F : $short_in -> $short_out",
"",
"rule compile_touches_{id}",
"rule compile_touches_{id}",
" command = {FC} -c $in -o $out",
" description = F : $short_in -> $short_out",
" description = F : $short_in -> $short_out",
"",
"",
"rule compile_c_{id}" ,
" command = {CC} {CFLAGS} -c $in -o $out",
" description = C : $short_in -> $short_out",
" command = {CC} {CFLAGS} -c $in -o $out",
" description = C : $short_in -> $short_out",
"",
"rule compile_cxx_{id}",
" command = {CXX} {CXXFLAGS} -c $in -o $out",
" description = C++ : $short_in -> $short_out",
"rule compile_cxx_{id}",
" command = {CXX} {CXXFLAGS} -c $in -o $out",
" description = C++ : $short_in -> $short_out",
"",
"rule link_lib_{id}",
" command = {AR} $out $in" ,
" description = Link: $short_out",
"rule link_lib_{id}",
" command = {ARCHIVE} $out $in" ,
" description = Link: $short_out",
"",
"rule link_{id}",
"rule link_{id}",
" command = {FC} $in {LIB} -o $out" ,
" description = Link: $short_out"]
output += [ '\n'.join(t).format(id=irp_id, FC=FC, FCFLAGS=FCFLAGS, LIB=LIB, CXX=CXX, CXXFLAGS=CXXFLAGS, CC=CC, CFLAGS=CFLAGS, AR=AR) ]
" description = Link: $short_out"]
output += [ '\n'.join(t).format(id=irp_id, FC=FC, FCFLAGS=FCFLAGS, LIB=LIB, CXX=CXX, CXXFLAGS=CXXFLAGS, CC=CC, CFLAGS=CFLAGS, ARCHIVE=ARCHIVE) ]
# All modules : list of Fmodule objects
@ -396,7 +404,7 @@ def run():
for i in l_common_s:
output.append(create_build_remaining(i))
with open(FILENAME,'w') as f:
f.write('\n\n'.join(output))
f.write('\n')