File: Makefile.Win

package info (click to toggle)
units 2.25-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,824 kB
  • sloc: ansic: 6,836; sh: 899; python: 803; yacc: 605; makefile: 490; perl: 435
file content (145 lines) | stat: -rw-r--r-- 5,339 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
# Makefile for units, a program for units conversion
# created for Microsoft Visual C/C++ under Microsoft Windows(R)
#
# Copyright (C) 1996, 1997, 1999, 2005, 2006, 2012, 2013, 2014, 2017, 2020,
# 2022, 2024-25
# Free Software Foundation, Inc
#
# 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 3 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
#    
#
# The units program was written by Adrian Mariano (adrianm@gnu.org).
# This makefile was written by Adrian Mariano and Jeff Conrad
# (jeff_conrad@msn.com), and tested with Microsoft Visual Studio 2022
# on Windows 11 Professional.
# It was previously tested with MS Visual Studio 2015 and MS Visual Studio
# 2019 on Windows 10 Professional, and before that, with MS Visual C/C++ 6.0,
# and MS Visual Studio 2005, 2008, and 2010 on Windows XP Professional SP3.

# Change these to suit the system configuration
# Normal location on 32-bit system
# ProgFilesDir = %ProgramFiles%
# Normal location for 32-bit executable on 64-bit system
# ProgFilesDir = %ProgramFiles(x86)%
# Normal location on 64-bit system
ProgFilesDir = %ProgramFiles%
ProgFilesPath = ^%%ProgramFiles^%%

exefile = units.exe
bindir =  "$(ProgFilesDir)\GNU\units"
datadir = "$(ProgFilesDir)\GNU\units"
pathdir = "$(ProgFilesPath)\GNU\units"

srcdir = .

# These are for Microsoft Visual Studio; edit to suit for other compilers.
# Do NOT give the 'Za' flag with MSVC.

CC = cl
RC = rc.exe
RES = units.res

.rc.res:
	$(RC) /fo $@ $<

CFLAGS = /O2 /W3 /nologo

OBJS = units.obj getopt.obj getopt1.obj parse.tab.obj

# suppress warnings about "unsafe" functions
CDEFS = /DNO_SETENV /D_CRT_SECURE_NO_WARNINGS
# add this to CDEFS if compiler version doesn't have isfinite()
# /DNO_ISFINITE
UDEFS = /DUNITSFILE=\"definitions.units\" /DLOCALEMAP=\"locale_map.txt\"
RES = units.res

all: units.exe units_cur.py

units.exe: $(OBJS) $(RES)
	$(CC) $(CFLAGS) $(CDEFS) $(UDEFS) $(OBJS) $(RES) $(LIBS)

getopt.obj: getopt.c
	$(CC) $(CFLAGS) $(CDEFS) /c getopt.c

getopt1.obj: getopt1.c getopt.h
	$(CC) $(CFLAGS) $(CDEFS) /c getopt1.c

units.obj: units.c units.h
	$(CC) $(CFLAGS) $(CDEFS) $(UDEFS) /c units.c

parse.tab.obj: parse.tab.c units.h
	$(CC) $(CFLAGS) $(CDEFS) /c parse.tab.c

units_cur.py: units_cur
	copy units_cur units_cur.py

showdest:
	@echo datadir=$(datadir) & echo bindir=$(bindir)
	@if not exist "$(ProgFilesDir)" \
	  echo '$(ProgFilesDir)' does not exist and will be created

echo:
	echo $(bindir) $(datadir)

install: all
	$(srcdir)\winmkdirs $(bindir) $(datadir)
	copy /y units.exe $(bindir)
	copy /y definitions.units $(datadir)
	copy /y currency.units $(datadir)
	copy /y cpi.units $(datadir)
	copy /y elements.units $(datadir)
	copy /y locale_map.txt $(datadir)
	copy /y unitsfile.ico $(datadir)
	copy /y unitsprog.ico $(datadir)
	cacls $(datadir)\definitions.units /e /g Users:c
	cacls $(datadir)\definitions.units /e /g "Power Users":c
	cacls $(datadir)\currency.units /e /g Users:c
	cacls $(datadir)\currency.units /e /g "Power Users":c
	cacls $(datadir)\cpi.units /e /g Users:c
	cacls $(datadir)\cpi.units /e /g "Power Users":c
	cacls $(datadir)\elements.units /e /g Users:c
	cacls $(datadir)\elements.units /e /g "Power Users":c
	copy /y units_cur.py $(datadir)
	cacls $(datadir)\units_cur.py /e /g Users:c
	cacls $(datadir)\units_cur.py /e /g "Power Users":c

# associate an editor with units data files
# ensure that if the MKS Toolkit is installed, the cmd internal command
# is run rather than the assoc script
	cmd /c assoc .units=Units.DataFile
# change this if you want a different editor than notepad
	for %%i in (notepad.exe) do \
	  if exist %%~$$PATH:i (ftype Units.DataFile="%%~$$PATH:i" "%1") \
	  else (ftype Units.DataFile=notepad.exe "%1")
# associate icon with units data files
	reg add "HKCR\Units.DataFile\DefaultIcon" /f /ve /d $(datadir)\unitsfile.ico /t REG_SZ

Path:
# set user Path
	cmd /c set OldPath= & \
	for /f "tokens=3" %%i in ('reg query HKCU\Environment /v Path') do \
	    set "OldPath=%%i" & set unitspath=$(pathdir) & \
	if not "%%OldPath%%"=="" reg add HKCU\Environment /f /v Path /t REG_EXPAND_SZ /d %OldPath%;$(bindir) > NUL & \
	if not ERRORLEVEL 1 echo $(bindir) added to user Path

AppPath:
# set App Path for all users
	reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\$(exefile)" /f /ve /d $(bindir)\$(exefile) > NUL
	@if not ERRORLEVEL 1 echo $(bindir)\$(exefile) added to App Paths
	reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\$(exefile)" /f /v Path /d $(bindir) > NUL
	@if not ERRORLEVEL 1 echo $(bindir) added to App Paths

clean:
	-del /f/q $(OBJS) $(RES) units_cur.py