File: make-macros-autotools

package info (click to toggle)
abinit 9.10.4-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 518,712 kB
  • sloc: xml: 877,568; f90: 577,240; python: 80,760; perl: 7,019; ansic: 4,585; sh: 1,925; javascript: 601; fortran: 557; cpp: 454; objc: 323; makefile: 77; csh: 42; pascal: 31
file content (160 lines) | stat: -rwxr-xr-x 3,624 bytes parent folder | download
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env python3
#
# Copyright (C) 2009-2022 ABINIT Group (Yann Pouillon)
#
# This file is part of the ABINIT software package. For license information,
# please see the COPYING file in the top-level directory of the ABINIT source
# distribution.
#

from __future__ import print_function, division, absolute_import

from time import gmtime,strftime

try:
    from commands import getoutput
except:
    from subprocess import getoutput

import os
import re
import sys

# ---------------------------------------------------------------------------- #

#
# Subroutines
#

# Macro header
def macro_header(name,stamp):

  return """# Generated by %s on %s

#
# ABINIT Autotools info dumper for the "configure" script
#

#
# IMPORTANT NOTE
#
# This file has been automatically generated by the %s
# script. If you try to edit it, your changes will systematically be
# overwritten.
#
""" % (name,stamp,name)



# Autotools info macro
def macro_info(m4_version,ac_version,am_version,lt_version):

  return """


# ABI_INFO_AUTOTOOLS()
# --------------------
#
# Make information about the Autotools available.
#
AC_DEFUN([ABI_INFO_AUTOTOOLS],[
  dnl Store version numbers
  abi_m4_version="%6.6d"
  abi_ac_version="%6.6d"
  abi_am_version="%6.6d"
  abi_lt_version="%6.6d"

  dnl Display version information
  AC_MSG_NOTICE([reporting Autotools information:])
  AC_MSG_NOTICE([])
  AC_MSG_NOTICE([  * M4       : ${abi_m4_version}])
  AC_MSG_NOTICE([  * Autoconf : ${abi_ac_version}])
  AC_MSG_NOTICE([  * Automake : ${abi_am_version}])
  AC_MSG_NOTICE([  * Libtool  : ${abi_lt_version}])

  dnl Substitute variables
  AC_SUBST(abi_m4_version)
  AC_SUBST(abi_ac_version)
  AC_SUBST(abi_am_version)
  AC_SUBST(abi_lt_version)
]) # ABI_INFO_AUTOTOOLS
""" % (m4_version,ac_version,am_version,lt_version)



# Init macro for source and build dirs
def macro_init_dirs(ac_version):

  ret = """


# ABI_INIT_DIRS()
# ---------------
#
# Set paths to source and build directories.
#
AC_DEFUN([ABI_INIT_DIRS],[
  dnl Set paths (needed by other ABINIT macros)
  _AC_SRCDIRS(["."])
  abinit_srcdir="${ac_abs_top_srcdir}"
  abinit_builddir="${ac_abs_top_builddir}"
  
  export abinit_srcdir abinit_builddir

  AC_SUBST(abinit_srcdir)
  AC_SUBST(abinit_builddir)
]) # ABI_INIT_DIRS
"""

  return ret



# ---------------------------------------------------------------------------- #

#
# Main program
#

# Initial setup
my_name    = "make-macros-autotools"
my_output  = "config/m4/auto-autotools.m4"

# Check if we are in the top of the ABINIT source tree
if ( not os.path.exists("configure.ac") or
          not os.path.exists("src/98_main/abinit.F90") ):
  print("%s: You must be in the top of an ABINIT source tree." % my_name)
  print("%s: Aborting now." % my_name)
  sys.exit(1)

# What time is it?
now = strftime("%Y/%m/%d %H:%M:%S +0000",gmtime())

# Get Autotools versions
at_file = "./config/local/autotools.sh"
if ( os.path.exists(at_file) ):
  at_versions = open(at_file, "rt").read()
  exec(at_versions)
  m4_version = int(abi_m4_version)
  ac_version = int(abi_ac_version)
  am_version = int(abi_am_version)
  lt_version = int(abi_lt_version)
else:
  m4_version = 0
  ac_version = 0
  am_version = 0
  lt_version = 0
  sys.stderr.write(
    "[%s] WARNING: could not get Autotools version information" % \
      (my_name))

# Write macros
m4 = open(my_output,"wt")
m4.write(macro_header(my_name,now))
m4.write(macro_info(m4_version,ac_version,am_version,lt_version))
m4.write(macro_init_dirs(ac_version))
m4.close()

tmp = getoutput("./config/scripts/add-header-typed Autoconf %s" % (my_output))
if ( tmp != "" ):
  print(tmp)