Merge pull request #207012 from Homebrew/bump-tailwindcss-4.0.5
[Homebrew/homebrew-core.git] / Formula / g / gnu-complexity.rb
blob5e92b022081ac405f15e3753654f2a9c3b89ba07
1 class GnuComplexity < Formula
2   desc "Measures complexity of C source"
3   homepage "https://www.gnu.org/software/complexity/"
4   url "https://ftp.gnu.org/gnu/complexity/complexity-1.13.tar.xz"
5   mirror "https://ftpmirror.gnu.org/complexity/complexity-1.13.tar.xz"
6   sha256 "80a625a87ee7c17fed02fb39482a7946fc757f10d8a4ffddc5372b4c4b739e67"
7   license "GPL-3.0-or-later"
9   bottle do
10     sha256 cellar: :any,                 arm64_sequoia:  "cd060b26ae921fe515fb597c86e07eb82c0cad595d8eab8547cd421db5a249e3"
11     sha256 cellar: :any,                 arm64_sonoma:   "8e32f6384e57c2e21cce940fc39b2be2257b0a200367a48f85aee626988a9863"
12     sha256 cellar: :any,                 arm64_ventura:  "c61d3b1a378d7debac6a79e092b3828b68b455d0b555edcb02129b34945947b1"
13     sha256 cellar: :any,                 arm64_monterey: "d88523c95f66d61eab621059d46a31cae7da8964042c28499e49def45ddb6d40"
14     sha256 cellar: :any,                 arm64_big_sur:  "7561dae8dcc2422a456727c8fc7b9e8e2719fca7934f26118c32bb455f376ef5"
15     sha256 cellar: :any,                 sonoma:         "0b3ec86fc33aa631f44dd91525ff27e9b2c992e43acbf0ef1a1e71b4a78763be"
16     sha256 cellar: :any,                 ventura:        "4bef537bbe2199465336c8f1dcbd0c862564eb13cf2680d53671075cd6bda92e"
17     sha256 cellar: :any,                 monterey:       "288719f321641b768497edfae38f1ac88499b5274ce8ada8ea1c5cd30239078c"
18     sha256 cellar: :any,                 big_sur:        "82574a778a6b6ba218cd98fbd173bb7c15f4253fd871349abf8c1c322cbe99c7"
19     sha256 cellar: :any_skip_relocation, x86_64_linux:   "623e40ffaa4b67fb049c25a3cb3a781366fa19b316207b5f50d68ecccbb839dd"
20   end
22   # Drop `autoconf` and `automake` when the patch is removed.
23   depends_on "autoconf" => :build
24   depends_on "automake" => :build
25   depends_on "autogen"
27   # Fix build problem in doc. Borrowed from Debian.
28   patch do
29     url "https://salsa.debian.org/debian/complexity/-/raw/69a7b9d27eb5c2ba8aa43966518971df74d55657/debian/patches/01_fix_autobuild.patch"
30     sha256 "3c2403be83ae819bbdfe7d1b0f14e2637d504387d1237f15b24e149cd66f56b1"
31   end
33   def install
34     odie "check if autoreconf line can be removed" if version > "1.13"
35     # regenerate since the files were generated using automake 1.16.1
36     system "autoreconf", "--force", "--install", "--verbose"
38     # Fix errors in opts.h. Borrowed from Debian:
39     # https://salsa.debian.org/debian/complexity/-/blob/master/debian/rules
40     cd "src" do
41       system "autogen", "opts.def"
42     end
44     system "./configure", *std_configure_args
45     system "make"
46     system "make", "install"
47   end
49   test do
50     (testpath/"test.c").write <<~C
51       void free_table(uint32_t *page_dir) {
52           // The last entry of the page directory is reserved. It points to the page
53           // table itself.
54           for (size_t i = 0; i < PAGE_TABLE_SIZE-2; ++i) {
55               uint32_t *page_entry = (uint32_t*)GETADDRESS(page_dir[i]);
56               for (size_t j = 0; j < PAGE_TABLE_SIZE; ++j) {
57                   uintptr_t addr = (i<<20|j<<12);
58                   if (addr == VIDEO_MEMORY_BEGIN ||
59                           (addr >= KERNEL_START && addr < KERNEL_END)) {
60                       continue;
61                   }
62                   if ((page_entry[j] & PAGE_PRESENT) == 1) {
63                       free_frame(page_entry[j]);
64                   }
65               }
66           }
67           free_frame((page_frame_t)page_dir);
68       }
69     C
70     system bin/"complexity", "-t", "3", "./test.c"
71   end
72 end